from appium.webdriver.common.mobileby import MobileBy

from utils.common.basepage import pyappium


class App_login(pyappium):
    def login(self):
        self.click((MobileBy.XPATH, "//*[@text='同意']"))
        self.click((MobileBy.XPATH, "//*[@text='请输入手机号/邮箱']"))
        self.input((MobileBy.XPATH, "//*[@text='请输入手机号/邮箱']"),"13688400244")
        self.click((MobileBy.XPATH, "//*[@text='请输入密码']"))
        self.input((MobileBy.XPATH, "//*[@text='请输入密码']"),"12345678")
        self.click((MobileBy.XPATH, "//*[@text='登录']"))

class App_userInfo(pyappium):
    def nickName(self):
        self.click((MobileBy.XPATH, "//*[@text='我的']"))
        self.click((MobileBy.XPATH, "//*[contains(@text,'编辑个人资料')]"))
        self.click((MobileBy.XPATH, "//*[@text='昵称']"))
        self.click((MobileBy.XPATH, "//*[@text='修改昵称']/ancestor::android.widget.FrameLayout[1]/following-sibling::*/android.widget.EditText"))
        self.input((MobileBy.XPATH, "//*[@text='修改昵称']/ancestor::android.widget.FrameLayout[1]/following-sibling::*/android.widget.EditText"),"昵称")
        self.click((MobileBy.XPATH, "//*[@text='修改昵称']/ancestor::android.widget.FrameLayout[1]/following-sibling::*/android.widget.TextView"))
        self.sleep(1)
        self.get_element((MobileBy.XPATH,"//*[@text='昵称更新成功']"))
